import QtQuick
import QtQuick.Layouts
import QtQuick.Controls

import Fk
import Fk.Components.LunarLTK
import Fk.Pages.LunarLTK
import Fk.Components.Common

ColumnLayout {
  id: root
  anchors.fill: parent
  property var extra_data: ({ name: "", data: [] })
  signal finish()

  BigGlowText {
    Layout.fillWidth: true
    Layout.preferredHeight: childrenRect.height + 4

    text: Lua.tr(extra_data.name)
  }
  Item {
    width: parent.width
    height: parent.height

    Grid {
      //anchors.verticalCenter: parent.verticalCenter
      anchors.left: parent.left
      rows: Math.ceil(extra_data.data.length / 10)
      columns: 10
      rowSpacing: 5
      columnSpacing: 5
      Repeater {
        model: extra_data.data

        Item {  // 需要填入固定数值
          width: 88
          height: 36

          property var skillName: modelData[0] // 技能名
          property var prohibit: modelData[1] // 是否变灰

          SkillButton {
            anchors.fill: parent
            skill: Lua.tr(skillName)
            type: "active"
            orig: skillName
            enabled: !prohibit
          }
        }
      }
    }
  }

  onExtra_dataChanged: {
    // 如果传入的是字符串，转换为数组格式
    if (typeof(extra_data.data) == "string") {
      extra_data.data = [[extra_data.data]];
    }
  }
}